#!/bin/sh
if test $# -ne 2; then
	echo "Usage: $(basename $0) CONFIGFILE TEMPLATEFILE"
	exit 1
fi

STATE=$(mount | grep "ROOT_FS on / type" | cut -d"(" -f2 | head -c2)
test "$STATE" = "ro" && /usr/local/sbin/remountrw
uya --read-config -f "$1" -t "$2"
RETVAL=$?
test "$STATE" = "ro" &&	/usr/local/sbin/remountro
exit $RETVAL
